#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from jinja2 import Environment
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse


def jinja2_environment(**options):
    # 创建对象
    env = Environment(**options)
    # 自定义语法{{ static:('静态文件相对路径') }}{{ url:('路由命名空间') }}
    env.globals.update({
        'static': staticfiles_storage.url,  # 获取静态文件前缀
        'url': reverse,
    })
    return env



